<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/header.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>DSP</title>
<%@include file="../common/link.jsp"%>
<script src="javascript?type=province"></script>
<script src="javascript?type=selectTags"></script>
<script>
var config = {
		url : 'companys'
	}
var colModel = [
			{
				title : "二级代码",
				field : 'ccode',
				width : 80,
				formatter : function(value, rowData, rowIndex) {
					return "<a href='#' onclick='javascript:DSP.update("+ rowData.id + ");'>" + value + "</a>";
				}
			}, {
				title : '公司名称',
				field : 'cname',
				width : 140,
				align : 'left'
			}, {
				title : '代理方式',
				field : 'cMethod',
				width : 40,
				align : 'center'
			}, {
				title : '公司性质',
				field : 'cType',
				width : 80
			}, {
				title : '组织机构代码',
				field : 'orgCode',
				width : 120
			}, {
				title : '公司地址',
				field : 'caddress',
				width : 240,
				align : 'left'
			}, {
				title : '联系人',
				field : 'contact',
				width : 60,
				// sortable : true,
				align : 'center'
			} ];
	function update(data) {
		DSP.city(data.province, data.city);
		DSP.area(data.city, data.area);
		/**$("#id").attr("value", data.id);
		$("#ccode").attr("value", data.ccode);
		$("#span_ccode").text(data.ccode);
		$("#cname").attr("value", data.cname);
		$("#caddress").attr("value", data.caddress);
		$("#contact").attr("value", data.contact);
		$("#province").attr("value", data.province);
		$("#city").attr("value", data.city);
		$("#area").attr("value", data.area);
		$("#job").attr("value", data.job);
		$("#phone").attr("value", data.phone);
		$("#telphone").attr("value", data.telphone);
		$("#fax").attr("value", data.fax); */
		$_("id").value = data.id;
		$_("ccode").value = data.ccode;
		// $_("span_ccode").innerHTML = data.ccode;
		$_("cMethod").value = data.cMethod;
		$_("cType").value = data.cType;
		$_("orgCode").value = data.orgCode;
		$_("cname").value = data.cname;
		$_("caddress").value = data.caddress;
		$_("contact").value = data.contact;
		$_("province").value = data.province;
		$_("city").value = data.city;
		$_("area").value = data.area;
		$_("job").value = data.job;
		$_("phone").value = data.phone;
		$_("telphone").value = data.telphone;
		$_("fax").value = data.fax;
		$_("insureBase").value = data.insureBase;
		$_("providentBase").value = data.providentBase;
	}
	function CallBackFunc() {
		$('#city').empty().append("<option value=''>请选择市</option>");
		$("#area").empty().append("<option value=''>请选择区</option>");
	}
</script>
</head>
<body>
	<form id="qForm">
		<table width="60%" cellspacing="3" cellpadding="3"
			bordercolor="#DEDEDC" border="0" id="q-form" >
			<tr>
				<th width="15%" class="td_left" valign="middle">二级代码:</th>
				<td width="20%"><input type="text" name="q_ccode" id="q_ccode" />
				</td>
				<th width="15%" class="td_left" valign="middle">公司名称:</th>
				<td width="20%"><input type="text" name="q_cname" id="q_cname" />
				</td>
			</tr>
			<tr>
				<th width="15%" class="td_left" valign="middle">代理方式:</th>
				<td><input type="text" name="q_cMethod" id="q_cMethod" />
				</td>
				<th class="td_left" valign="middle">公司性质:</th>
				<td><input type="text" name="q_cType" id="q_cType" />
				</td>
			</tr>
			<tr>
				<th width="10%" class="td_left" valign="middle">组织机构代码:</th>
				<td><input name="q_orgCode" id="q_orgCode" type="text" />
				</td>
				<th class="td_left" valign="middle">联系人:</th>
				<td><input name="q_contact" id="q_contact" type="text" />
				</td>
			</tr>
		</table>
		</form>
	<div id="dialog_div" class="easyui-window" title="公司资料信息"
		collapsible="false" minimizable="false" maximizable="false"
		icon="icon-save"
		style="width: 310px; height: 600px; left: 200px; top: 10px; padding: 5px; background: #fafafa;">
		<div class="easyui-layout" fit="true">
			<div region="center" border="false"
				style="padding: 10px; background: #fff; border: 1px solid #ccc;">
				<form action="" id="form1">
					<input type="hidden" name="id" id="id"value="" />
					<table width="100%" cellspacing="3" cellpadding="3"
						bordercolor="#DEDEDC" border="0" id="id-form">
						<tr height="21">
							<th width="25%" class="td_right" valign="middle"><span style="color: #FF0000">*</span>公司编码:</th>
							<td colspan="3"><input type="text" name="ccode" id="ccode" maxlength="50" 
							jval="{valid:function(val){if (val.length == 0) return '二级代码不能为空'; else return '' }}"
							/> <span>唯一性</span></td>
						</tr>
						<tr>
							<th class="td_right" valign="middle"><span
								style="color: #FF0000">*</span>公司名称:</th>
							<td colspan="3"><input type="text" name="cname" id="cname"
								jval="{valid:function(val){if (val.length ==0) return '公司名称不能为空'; else return '' }}"
								maxlength="100" value="" /> </td>
							</tr><tr>
							<th class="td_right" valign="middle"><span style="color:#FF0000">*</span>代理方式:</th>
							<td colspan="3"><input type="text" name="cMethod" id="cMethod" maxlength="2" value=""
								jval="{valid:function(val){if (val.length == 0) return '代理方式不能为空'; else return '' }}">
							</td>
						</tr>
						<tr>
							<th class="td_right" valign="middle"><span style="color:#FF0000">*</span>公司性质:</th>
							<td colspan="3"><input type="text" name="cType" id="cType" maxlength="20" value=""
								jval="{valid:function(val){if (val.length == 0) return '公司性质不能为空'; else return '' }}">
							</td>
									</tr><tr>
							<th class="td_right" valign="middle"><span style="color:#FF0000">*</span>组织机构代码:</th>
							<td colspan="3"><input type="text" name="orgCode" id="orgCode" maxlength="30" value=""
								jval="{valid:function(val){if (val.length == 0) return '组织机构代码不能为空'; else return '' }}">
							</td>
						</tr>
						<tr>
							<th class="td_right" valign="middle"><span
								style="color: #FF0000">*</span>公司地址 :</th>
							<td colspan="3"><input type="text" name="caddress" id="caddress"
								size="32"
								jval="{valid:function(val){ if (val.length ==0 ) return '公司地址不能为空'; else return '';}}" />
							</td>
						</tr>
						<tr>
							<th class="td_right" valign="middle"><span
								style="color: #FF0000">*</span>省..市..区:</th>
							<td colspan="3"><select id="province" name="province"
								jval="{valid:function(val){ if (val.length==0) return '不能为空' ; else return '';}}">
									<option value="">请选择</option>
							</select>
							<select id="city" name="city"
								jval="{valid:function(val){ if (val.length==0) return '不能为空' ; else return '';}}">
									<option value="">请选择</option>
							</select>
							<select id="area" name="area"
								jval="{valid:function(val){ if (val.length==0) return '不能为空' ; else return '';}}">
									<option value="">请选择</option>
							</select></td>
						</tr>
							<tr>
								<th class="td_right" valign="middle">社保基数</th>
								<td><input type="text" name="insureBase" id="insureBase"></td>
								<th class="td_right" valign="middle">公积金基数</th>
								<td><input type="text" name="providentBase" id="providentBase"></td>
							</tr>
							<tr>
							<th class="td_right" valign="middle">联系人 :</th>
							<td><input type="text" name="contact" id="contact" />
							</td>
							<th class="td_right" valign="middle">职位 :</th>
							<td><input type="text" name="job" id="job" /></td>
						</tr>
						<tr>
							<th class="td_right" valign="middle">手机 :</th>
							<td><input type="text" maxlength="11" name="phone" id="phone" />
							</td>
							<th class="td_right" valign="middle">电话--分机:</th>
							<td><input type="text" name="telphone" id="telphone"
								maxlength="11"
								jValKey="{valid:/[0-9]/, message:'&quot;%c&quot; Invalid Character - Only Digits Allowed', cFunc:'$(\'#formContainer\').jVal()'} " />
								--<input type="text" name="fax" id="fax" maxlength="4" style="width:30px;"
								jValKey="{valid:/[0-9]/,message:'只能输入数字型', cFunc:'$(\'#formContainer\').jVal()'}"/>
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div region="south" border="false"
				style="text-align: right; height: 30px; line-height: 30px;">
				<a id="btnEp" class="easyui-linkbutton" icon="icon-ok"
					href="javascript:DSP.send();"> 确定</a> <a id="btnCancel"
					class="easyui-linkbutton" icon="icon-cancel"
					href="javascript:DSP.close();">取消</a>
			</div>
		</div>
	</div>
	<script>
		$(function() {
			DSP.open(false, 520, 620, "");
			DSP.grid(colModel,false,null,"公司资料信息");
			//监听查询输入框事件
			$("#q-form input").keyup(function(event){
				var e = event || window.event; //浏览器兼容
				if(e.keyCode == 13){ 
					 DSP.grid.query();
				}
			});
			
			DSP.province();
			$("#province").change(function() {
				$("#city").empty().append("<option value=''>请选择市</option>");
				$("#area").empty().append("<option value=''>请选择区</option>");
				var item = $("#province").val();
				if(item != ''){
					DSP.city(item);
				}
			});
			$("#city").change(function() {
				$("#area").empty().append("<option value=''>请选择区</option>");
				var item = $("#city").val();
				if (item != ''){
					DSP.area(item);
				}
			});
		});
	</script>
	<table id="xDataGrid"></table>
</body>
</html>
